home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-21 | 4.5 KB | 223 lines | [TEXT/CWIE] |
- //===================================================================
- //======================= Headers =============================
- #include "MacOSEvents.h"
- #include "GameTypes.h"
- #include "Screen.h"
- #include "MenuBar.h"
- #include "ApplicationHandler.h"
-
- #include <string.h>
- //===================================================================
- //======================= Globals =============================
-
- RgnHandle rgn;
- point last; // last location of mouse
-
- //===================================================================
- //======================= #define =============================
-
-
- //===================================================================
- //======================= Function Prototypes =====================
-
- void Handle_Key( char key );
- void HandleMouseClick( Boolean down , point where );
- void HandleMouseMove( point where );
-
-
-
- void InitEvents( void )
- {
- rgn = NewRgn();
- SetRectRgn( rgn , 0 , 0 , 1024, 768 );
-
- last.x = last.y = 0;
- }
-
-
- /*----------------------------------------------------------------------------\
-
- HandleMouseClick
-
- \----------------------------------------------------------------------------*/
-
- void HandleMouseClick( Boolean down , point where )
- {
- if( down )
- {
- if( !menuBar.HandleMouseClick( down , where ) )
- {
- AH.HandleMouseClick( down , where );
- }
- }
- else
- {
- AH.HandleMouseClick( down , where );
- menuBar.HandleMouseClick( down , where );
- }
- }
-
- /*----------------------------------------------------------------------------\
-
- HandleMouseMove
-
- \----------------------------------------------------------------------------*/
-
- void HandleMouseMove( point where )
- {
- AH.HandleMouseMove( where );
- menuBar.HandleMouseMove( where );
- }
-
- /*----------------------------------------------------------------------------\
-
- HandleInterface
-
- this is where most of the interface is handled - MAcOS
-
- \----------------------------------------------------------------------------*/
-
- void HandleInterface( void )
- {
- WindowPtr whichWindow;
- EventRecord theEvent;
- long whichPart;
- char theKey = 0;
- Point diskInitPt = {40,40};
- static next = 0;
-
-
-
- WaitNextEvent(everyEvent, &theEvent, 0L, rgn );
-
- Point mouse;
-
- GetMouse( &mouse );
-
- if(( mouse.h != last.x || mouse.v != last.y ) &&
- ( mouse.h > 0 && mouse.v > 0 ) )
- {
- last.x = mouse.h;
- last.y = mouse.v;
-
- HandleMouseMove( last );
- }
-
- switch ( theEvent.what )
- {
- case mouseDown:
-
- whichPart = FindWindow(theEvent.where, &whichWindow);
- switch ( whichPart )
- {
- case inMenuBar:
- whichPart = MenuSelect( theEvent.where );
- break;
-
- case inSysWindow:
- SystemClick(&theEvent, whichWindow);
- break;
-
- case inGoAway:
-
- break;
-
- case inDrag:
- break;
-
- case inGrow:
-
- break;
-
- case inContent:
-
- point pt;
- GlobalToLocal( &theEvent.where );
- pt.x = theEvent.where.h;
- pt.y = theEvent.where.v;
-
- HandleMouseClick( true , pt );
- break;
- }
- break;
-
- case mouseUp:
- point pt;
- GlobalToLocal( &theEvent.where );
- pt.x = theEvent.where.h;
- pt.y = theEvent.where.v;
-
- HandleMouseClick( false , pt );
- break;
-
- case keyDown:
- case autoKey:
- theKey = (char)(theEvent.message & charCodeMask);
- // if ( ( (theEvent.modifiers & cmdKey) != 0) )
- // Handle_Menu_Choice(MenuKey(theKey));
- // else
- Handle_Key( theKey );
-
- break;
-
- case updateEvt:
- BeginUpdate( (WindowPtr)theEvent.message );
- screen.DrawAll();
- EndUpdate( (WindowPtr)theEvent.message );
-
- break;
-
- case activateEvt:
- break;
-
- case osEvt:
- switch((theEvent.message >> 24) & 0x000000FF)
- {
- case suspendResumeMessage:
- /* if( (theEvent.message & resumeFlag) )
- background = false; // in foreground
- else
- background = true; //in background */
- break;
-
- case mouseMovedMessage:
- point pt;
-
- GlobalToLocal( &theEvent.where );
- pt.x = theEvent.where.h;
- pt.y = theEvent.where.v;
-
- break;
-
- default:
-
- break;
- }
-
- break;
-
- case diskEvt:
- //Handle bad disk insertions
- if (HiWord(theEvent.message) != noErr)
- {
- DILoad();
- DIBadMount(diskInitPt, theEvent.message);
- DIUnload();
- }
- break;
-
- default:
- break;
- }; //case
- }
-
- /*----------------------------------------------------------------------------\
-
- Handle_File_Choice
-
- \----------------------------------------------------------------------------*/
-
- void Handle_Key( char key )
- {
- //ExitToShell();
- }